<?php

/**
* First part text cut
* @author: trungdt
* @since: Feb 11, 2011 
* @version: 1.0
* 
*/

function smarty_modifier_first_part($string, $strtype, $type) {
	$sep = ($strtype == "html" ? array("<br />","</p>","</div>") : array("."));
	switch ($type) {
		case "para":
			foreach ($sep as $s) {
				$para = explode($s,$string);
				$string = $para[0];
			}
			return strip_tags($string);
			break;
		default:
			$words = split(" ",strip_tags($string));
			return implode(" ",array_slice($words,0,$type+0));
			break;
	}
}

?>
